Luis Caballero Diaz's profile

Nasdaq Stock API for Financial Analysis

This project uses a stock API to calculate financial data of some stocks belonging to a particular sector, apply special ratios which are not included in most common screeners and write the output data in an output excel file. The script is created with Python.


This project is a very good example to use data API and data postprocessing, as well as output writing and input reading file. The actions performed by this script are as follows:

1. Read CSV file with all tickers in Nasdaq (that information is daily updated by the own stock exchange --> https://www.nasdaq.com/market-activity/stocks/screener). To read the tickers in Nasdaq, the csv library is used. 

2. Identify all tickers referred to Banks in the US. It can be done since there are several concepts to filter such as country, market cap, sector and industry after postprocessing the input CSV file.

3. Use a stock API to get the financial data of each one of the detected Banks. The used API for this particular run was Alpha Vantage and it provides a free key with limited output data acquisition (in the below code the API key is defined to XXXX, but each user should use his/her own key). This requires to use the library requests with Python. The free key allows 5 requests per minute and so the code include a 12 second delay after each request.

4. Summarize the most important financial data as well as calculating special ratios not included in the most common screeners. There are some strong parameters measuring the health of the balance sheet, which is very important for any stock, specially in the finance sector and in front of an upcoming recession. The script calculates some parameters to assess the business capitalization (how much is capitalized by equity and how much by debt), the loans to deposits ratio to see how margin has to provide new loans at high rate as the current environment or an equity to assets ratio to know how well covered are the current loans.

Running the script automatically generates an excel file in which can be filtered potential stocks with promising outcome thanks to the robustness of the balance sheet. Take into account that the current exercise helps to find potential promising stocks, but for sure these stocks should be assessed in more detail prior to purchase them. 

A screenshot of the autogenerated excel after code execution is depicted below. However, the complete excel file can be found attached in this project. 
Note the exercise in this project sets the basis to make any website data downloading and postprocess that data for any particular application. This example as reference is focused on financial sector, but it might be extended to any sector or application.

I appreciate your attention and I hope you find this work interesting.

Luis Caballero
Nasdaq Stock API for Financial Analysis
Published:

Nasdaq Stock API for Financial Analysis

Published:

Creative Fields